Add guideline for defining the name of a controller#8528
Open
Conversation
There is no written standard for defining the name of a controller, and some contributors do not have a common understanding of the do's and dont's for the name. This commit adds such a guideline, highlighting the following points: - The name of a controller should be defined in a variable called `CONTROLLER_NAME` (formerly `controllerName`) - The name should be used to define custom actions and events and should be passed to `BaseController` - The name should not be exported from the package
Contributor
Author
|
Adding |
Mrtenz
reviewed
Apr 21, 2026
|
|
||
| Every controller has a name, which is not only used to namespace the controller's messenger actions and events, but also to namespace the controller's state data when composed with other controllers. | ||
|
|
||
| The name should be defined in a constant called `CONTROLLER_NAME` so that it can be easily changed if the need arises. (This variable was formerly called `controllerName`.) The name should be used to initialize the messenger, and should also be passed to the `BaseController` constructor. |
Member
There was a problem hiding this comment.
Probably not necessary to include this.
Suggested change
| The name should be defined in a constant called `CONTROLLER_NAME` so that it can be easily changed if the need arises. (This variable was formerly called `controllerName`.) The name should be used to initialize the messenger, and should also be passed to the `BaseController` constructor. | |
| The name should be defined in a constant called `CONTROLLER_NAME` so that it can be easily changed if the need arises. The name should be used to initialize the messenger, and should also be passed to the `BaseController` constructor. |
Mrtenz
reviewed
Apr 21, 2026
|
|
||
| const CONTROLLER_NAME = 'FooController'; | ||
|
|
||
| export type FooControllerSomeCustomAction = { |
Member
There was a problem hiding this comment.
This example doesn't really make sense given the MESSENGER_EXPOSED_METHODS pattern. Maybe update it to use ControllerGetStateAction or some events?
Contributor
Author
There was a problem hiding this comment.
Yeah, you're right. In fact most of the examples in this document don't make much sense anymore 😅 I will update this.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explanation
There is no written standard for defining the name of a controller, and some contributors do not have a common understanding of the do's and dont's for the name.
This commit adds such a guideline, highlighting the following points:
CONTROLLER_NAME(formerlycontrollerName)BaseControllerBesides updating the guidelines, this commit also updates the
sample-controllerspackage to follow them, most notably changingcontrollerNametoCONTROLLER_NAMEand removing theexportfrom this constant.References
Checklist
Note
Low Risk
Low risk documentation and sample-code refactor; the only potential impact is for any downstream code importing
controllerNamedirectly from sample controller source files rather than via the package’s public exports.Overview
Adds a new controller guideline recommending an internal
CONTROLLER_NAMEconstant to namespace messenger actions/events and controller state, and explicitly discouraging exporting that constant from the package.Updates the
sample-controllersexamples to follow the guideline by renamingcontrollerNametoCONTROLLER_NAME, making it non-exported, and wiring all relatedMessenger/BaseControllertype parameters andnameinitialization to the new constant.Reviewed by Cursor Bugbot for commit 85bcaf7. Bugbot is set up for automated code reviews on this repo. Configure here.